<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/component/common.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" ></meta>
    <title>详细内容</title>
    <link rel="stylesheet" href="${frames}/css/lib/bootstrap.min.css" type="text/css" type="text/css">
    <%@ include file="/WEB-INF/jsp/component/commonBottom.jsp" %>
    <script type="text/javascript" src="../assets/js/echarts.js"></script>
    <link href="../assets/css/bootstrap-datetimepicker.css" type="text/css">
    <script src="../assets/js/bootstrap-datetimepicker.min.js"></script>
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="../assets/css/bootstrapDatepickr-1.0.0.css">
    <script src="../assets/js/bootstrapDatepickr-1.0.0.min.js"></script>
    <%--<link rel="stylesheet" href="${frames}/css/lib/dataTables.bootstrap.css" type="text/css">--%>
    <link rel="stylesheet" href="${frames}/css/paginate.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/base/base.css" type="text/css">
    <%--<link rel="stylesheet" href="${frames}/css/table.css" type="text/css">--%>
    <%--<link rel="stylesheet" href="${frames}/css/qulitity.css" type="text/css" type="text/css">--%>
    <script src="${frames}/Chronic/laydate/laydate.js"></script>
    <%--<script src="${assets}/js/views/bpAbnormal.js"></script>--%>
    <link rel="stylesheet" href="../assets/css/views/modules/_common.scss">
    <link rel="stylesheet" href="${assets}/css/views/department/departmentMgr.css">
    <style>
        span{
            font:15px/33px 微软雅黑;
            display:inline-block;
        }
        a{
            text-decoration:none;
        }
        .page_nav li{
            list-style:none !important;
        }
        .page_nav li span{
            margin:0 !important;
        }
        h4{
            font:22px/34px 微软雅黑;
            color:black;
        }
        h3{
            font-family: MicrosoftYaHei;
            font-size: 20px;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0px;
            color: #2a3137;
        }
        .title{
            line-height:25px;
            margin-bottom: 5px;
            font-size:16px;
            color:#666666;
            margin-left:10px;
        }
        .title1{
            line-height:25px;
            font-size:16px;
            color:#666666;
            margin-left:10px;
            margin-top:5px;
        }
        .test{
            width:95%;
            overflow:hidden;
            margin-top:15px;
        }
        .test p{
            width:100%;
            line-height:100px;
            font-size:15px;
            text-align:center;
        }
        thead tr th{
            text-align:center;
            /*width:14.2% !important;*/
        }
        /*thead hr{*/
        /*border-top: none !important;*/
        /*border-bottom: none !important;*/
        /*}*/
        #tablepart #example tbody tr td{
            font-family: MicrosoftYaHei;
            font-size: 16px;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0px;
            color: #333333;
        }
        #tablepart #example tbody tr{
            height:42px !important;
        }
        #tablepart #example tbody tr{
            border-bottom:1px solid #e6e6e6 !important;
        }
        #tablepart #example thead tr th{
            font-family: MicrosoftYaHei;
            font-size: 16px;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0px;
            color: #999999;
        }
        .dataTable{
            text-align:center;
        }
        .daterange i {
            position: absolute;
            bottom: 10px;
            right: 14px;
            top: auto;
            cursor: pointer;
        }
        .daterange {
            position: relative;
        }
        .container1{
            display:inline-block;
            width:100%;
            margin-top:15px;
        }
        .times{
            display:inline-block;
            width:10%;
        }
        .add{
            float: right;
            width: 100px;
            font-size: 16px;
            line-height: 25px;
        }
        .pagewidth{
            margin-top:26px;
        }
        .add{
            width:100px;
            font-size:16px;
            line-height:30px;
            background:#35acfd !important;
            margin-right:15px !important;
            padding:0 !important;
        }
        .search{
            width:100px;
            font-family: MicrosoftYaHei;
            font-size: 16px;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0px;
            color: #ffffff;
            line-height:16px;
            background:#35acfd;
            height:34px !important;
        }
        #calendar1{
            height: 34px;
            border-radius: 5px;
            border: solid 1px #d0d0d0;
        }
        /*#bootstrapDatepickr-table{*/
            /*margin-top:50px;*/
        /*}*/
        .bootstrapDatepickr-cal{
            top:170px !important;
        }
        img{
            max-width:100%;
            height:auto;
        }
        #example_paginate{
            width:100%;
            text-align: center;
        }
        .pagination{
            text-align: center;
        }
        thead tr{
            background:#e6e6e6;
        }
        input{
            width:100%;
            line-height: 32px;
            border-radius: 5px;
            border: solid 1px #d0d0d0;
        }
        input[type=checkbox] {
            width:20px !important;
            height:20px;
            display:block !important;
            -webkit-appearance: none;
            border-radius:5px;
            border:1px solid #9e9e9e;
            margin:0 auto;
        }
        input[type=checkbox]:checked{
            background-image: url('../assets/images/radio.png');
            background-size:100% 100%;
            border:none
        }
        .dataTables_empty{
            line-height:30px;
        }
        #tablepart{
            margin-bottom:-20px;
        }
    </style>
</head>
<body>
<div>
    <%@ include file="../../breadline.jsp" %>
</div>
<div class="wrap">
    <div id="main" class="content">
        <div style="width:99%;overflow:hidden;background-color: #ffffff;box-shadow: 0px 3px 7px 0px rgba(0, 0, 0, 0.05);">
            <div style="margin-left:19px;width:97%;margin-top:20px;">
                <div>
                    <h3 style="display:inline-block;">生命特征</h3>
                </div>
                <div style="float:right;width:400px;margin-top:15px;">
                    <button type="button" class="btn btn-info search" onclick="toAddMedical();" style="margin-left:20px;">
                        <img src="../assets/images/add.png" alt="" style="width:16px;vertical-align: middle;"> 添加
                    </button>
                    <button type="button" class="btn btn-info search" onclick="deletMedical();" style="margin-left:20px;">
                        删除
                    </button>
                    <button type="button" class="btn btn-info search" onclick="UpdateMedical();" style="margin-left:20px;">
                        <img src="../assets/images/revise.png" alt="" style="width:16px;vertical-align: middle;"> 修改
                    </button>
                </div>
                <div id="tablepart">
                    <table id="example" class="display" cellspacing="10" width="100%">
                        <thead>
                            <tr>
                                <th style="width:25px;">&nbsp;</th>
                                <th style="width:90px;">序号</th>
                                <th style="display:1%;"></th>
                                <th>体温</th>
                                <th>脉搏</th>
                                <th>呼吸</th>
                                <th>收缩压</th>
                                <th>舒张压</th>
                                <th>记录时间</th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function initLayDate(id) {
        laydate({
            elem: id,
            istime: true,
            format: 'YYYY-MM-DD',
            choose: function (dates) { //选择好日期的回调
//                initLineTable();
            }
        })
    }
    // boot时间选择器插件
    /*$(document).ready(function() {
        initLayDate('#beginDate');
        initLayDate('#endTime');
    });*/

    var table;
    // 获取当前idcard
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    //获取ID
    var arr = vars[0].split("=");
    var id = arr[1];
    var arr1 = vars[1].split("=");
    var idcard = arr1[1]
    var arr2 = vars[2].split("=")
    var diseasesType = arr2[1]
    function toAddMedical(){
        let that = this;
        // 新增用药信息页面 跳转
        // 获取病人id
        window.parent.showNewModelIframe('${URL_PATIENT_TOADDVITALCHARACTERISTICS}?id='+idcard + '&idCard=' + idcard + '&diseasesType='+diseasesType,500,600);
    }
    var idCard = '${URL_PATIENT_VITALCHARACTERISTICSINFO}?idCard='+idcard
    var times;
    var begintime;
    var medicalname;
    function search(){
        refreshTable()
    }
    function refreshTable(){
        table.ajax.reload();
        //重置全选按钮
        $(".all_id")[0].checked = false;
    }
    function deletMedical(){
        let that = this;
        var checkedArray = []
        var input = $('.all_id')
        for( var a = 0; a < input.length; a++ ){
            if( input[a].checked ){
                checkedArray.push(input[a])
            }
        }
        if( checkedArray.length != 1 ){
            var str = '请勾选一条数据修改'
            window.parent.showNewModelIframe('${URL_COMMON_TOTIPS}?title='+ encodeURI(encodeURI(str)),380,220)
        }else{
            var td = checkedArray[0].parentNode.parentNode.childNodes
            var id = td[2].firstChild.innerText;
            $.ajax({
                url:"${URL_PATIENT_DELETEVITALCHARACTERISTICS}",
                dataType:'json',
                type:'post',
                data:{
                    ids : id
                },
                success:function(data){
                    refreshTable();
                }
            })
        }
    }
    function UpdateMedical(){
        let that = this;
        var checkedArray = []
        var input = $('.all_id')
        for( var a = 0; a < input.length; a++ ){
            if( input[a].checked ){
                checkedArray.push(input[a])
            }
        }
        if( checkedArray.length != 1 ){
            alert('请勾选至少一项数据')
            return
        }else{
            var td = checkedArray[0].parentNode.parentNode.childNodes
            console.log(td)
            var minimumPressure = encodeURI(td[6].innerText)
            var breath = encodeURI(td[5].innerText)
            var pulse = td[4].innerText
            var id = td[1].title
            var temperature = encodeURI(td[3].innerText)
            var highestPressure = td[7].innerText
            window.parent.showNewModelIframe('${URL_PATIENT_TOUPDATEVITALCHARACTERISTICS}?id=' + id
                + '&temperature=' + temperature + '&pulse=' + pulse + '&breath=' + breath +
                '&minimumPressure=' + minimumPressure + '&highestPressure=' + highestPressure ,800,600);
        }
    }
    var ListNum = 0;
    var bb = 0;
    var arr2 = [];
    var arr1 = [];
    function initTable() {
        table = $('#example').DataTable({
            "dom": "<'row'<'col-xs-2'l><'#mytool.col-xs-10'><'col-xs-6'f>r>" +
            "t" +
            "<'row'<''i><col-xs-6'p>>",
            "bFilter": false,//去掉搜索框
            "bAutoWidth": true, //自适应宽度
            "bPaginate": true, //翻页功能
            "bSort": true, //排序功能
            "bAutoWidth": true,//自动宽度
            "info": false,
            "searching" : false, //去掉搜索框方法一
            'lengthChange' : false,
            "oPaginate":false,
            "bServerSide" : true,
            "lengthMenu": [10],
            "sAjaxSource":idCard,
            "sAjaxDataProp": "list",//查询后，返回的集合
            "fnServerData": function ( sSource, aoData, fnCallback ) {  //查询条件
                aoData.push(

                ),
                    $.ajax( {
                        "dataType": 'json',
                        "url": sSource,
                        "type":'post',
                        "data": aoData,
                        "success": function(resp){
                            if( ListNum == 0 ){
                                bb = 1
                            }
                            var arr3 = []
                            for ( var a = 0; a < resp.data.iTotalDisplayRecords; a++ ){
                                arr3.push(a+1)
                            }
                            var arr1 = arr3.slice((bb-1)*10,bb*10);
                            for( var a = 0 ; a < arr1.length; a++ ){
                                resp.data.list[a].oldNumber = arr1[a]
                            }
                            fnCallback(resp.data)
                            var alis = $('.pagination li')
                            var lisa = alis.slice(1,alis.length-1)
                            for( var a = 0; a < lisa.length; a++ ){
                                $(lisa[a]).on('click',function(){
                                    bb = $(this).find('a').text()
                                })
                            }
                            $(alis[0]).on('click',function(){
                                if( bb != 0 ){
                                    bb --;
                                }
                            })
                            $(alis[alis.length-1]).on('click',function(){
                                if( bb < lisa.length ){
                                    bb++;
                                }
                            })
                            ListNum++;
                        }
                    } );
            },
            "aoColumns" : [{
                "targets": 0,
                "data": null,
                "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                    $(nTd).html('<input class="all_id" type="checkbox">'+'<span style="display:none;">'+ oData.type +'</span>')
                }

            },{
                "targets": 1,
                "data": null,
                "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                    $(nTd).text(oData.oldNumber)
                    $(nTd).attr('title',oData.id)
                }
            },{
                "targets": 2,
                "data": null,
                "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                    $(nTd).html('<span style="display:none">'+oData.id+'</span>')
                }
            },{
                "targets": 3,
                "data": null,
                "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                    $(nTd).text(oData.temperature)
                    $(nTd).attr('title',oData.temperature)
                }
            },{
                "mDataProp" : "pulse"
            },{
                "mDataProp" : "breath"
            },{
                "mDataProp" : "minimumPressure"
            },{
                "mDataProp" : "highestPressure"
            },{
                "mDataProp" : "createTime"
            }],
            "oLanguage": {//插件的汉化
                "sLengthMenu": "32",
                "sZeroRecords" : "抱歉， 没有找到",
                "sInfoEmpty" : "没有数据",
                "sInfoFiltered" : "(从 _MAX_ 条数据中检索)",
                "oPaginate" : {
                    "sFirst" : "",
                    "sPrevious" : "<b>上一页<b>",
                    "sLast" : "",
                    "sNext" : "<i>下一页</i>"

                },
                "sZeroRecords" : "没有检索到数据",
                "sProcessing" : "<img src='' />",
                "sSearch" : "搜索"
            }
        } );
    }
    initTable()
</script>
</body>
</html>